<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('areasetting',$postdata);
		exi('设置成功');
	}
	$footernav =array(
		array('title'=>'代理中心','icon'=>'icon-shouye','action'=>'jy_guashop/area.index/'),
		array('title'=>'分红','icon'=>'icon-yiban','action'=>'jy_guashop/area.myfee/'),
		array('title'=>'区域订单','icon'=>'icon-dingdan','action'=>'jy_guashop/area.order/'),
		array('title'=>'代理地区','icon'=>'icon-paihao0','action'=>'jy_guashop/area.area/'),
	);	
	$return['item']=$this->plugin_setting('areasetting');
	$return['item']['footernav']=$return['item']['footernav']?:$footernav;
	$return['feetotal_types']=$this->feetotal_types;
	$return['fenxiaototal_types']=$this->fenxiaototal_types;
	$becomeset=array(
		array('area'=>'省级代理','area_type'=>1,'level_id'=>0,'jinfen'=>'1','fee'=>1,'nodel'=>1),
		array('area'=>'市级代理','area_type'=>2,'level_id'=>0,'jinfen'=>'1','fee'=>1,'nodel'=>1),
		array('area'=>'区级代理','area_type'=>3,'level_id'=>0,'jinfen'=>'1','fee'=>1,'nodel'=>1),
		array('area'=>'社区代理','area_type'=>4,'level_id'=>0,'jinfen'=>'1','fee'=>1,'nodel'=>1),
	);
	$return['item']['becomeset']=$return['item']['becomeset']?:$becomeset;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基础设置',
				'list'=>array(
					array('type'=>'tip','title'=>'[温馨提示]：代理分润：默认采用级差分润法！'),
                    array('type'=>'switch','title'=>'是否启用分红','name'=>'isopen','isradio'=>1),
					array('type'=>'radio','title'=>'申请条件','name'=>'become','options'=>'become'),
					array('type'=>'array','title'=>'申请扣除设置','name'=>'becomeset','noadd'=>1,'nosplice'=>1,
						'list'=>array(
							array('type'=>'string','name'=>'area','title'=>'级别'),	
							array('type'=>'select','name'=>'level_id','title'=>'团长等级','options'=>'levels'),
							array('type'=>'unitstring','unit'=>'个','name'=>'jinfen','title'=>'扣除金豆'),	
							array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'扣除余额'),							
						),
						'details'=>array(
							array('type'=>'copy','name'=>'area','title'=>'级别'),	
							array('type'=>'select','name'=>'level_id','title'=>'团长等级','options'=>'levels'),
							array('type'=>'unitstring','unit'=>'个','name'=>'jinfen','title'=>'扣除金豆'),	
							array('type'=>'unitstring','unit'=>'元','name'=>'fee','title'=>'扣除余额'),	
						)
					),
				)
			),
			array(
				'title'=>'分润设置',
				'list'=>array(
					array('type'=>'tip','title'=>'[温馨提示]：区域分润设置'),
                    array('type'=>'radio','title'=>'分润模式','name'=>'feetype','options'=>'types'),
					array('type'=>'string','title'=>'省级代理分润','name'=>'fee_1','help'=>'填写数字表示实际收益金额，填写百分数表示比例。例如填写1表示发放1元收益，填写1%表示发放商品价格1%的收益'),
					array('type'=>'string','title'=>'市级代理分润','name'=>'fee_2','help'=>'填写数字表示实际收益金额，填写百分数表示比例。例如填写1表示发放1元收益，填写1%表示发放商品价格1%的收益'),
					array('type'=>'string','title'=>'区级代理分润','name'=>'fee_3','help'=>'填写数字表示实际收益金额，填写百分数表示比例。例如填写1表示发放1元收益，填写1%表示发放商品价格1%的收益'),
					array('type'=>'string','title'=>'社区代理分润','name'=>'fee_4','help'=>'填写数字表示实际收益金额，填写百分数表示比例。例如填写1表示发放1元收益，填写1%表示发放商品价格1%的收益'),
				)
			),
			array(
						'title'=>'收益计算',
						'list'=>array(
							array('type'=>'checkbox','title'=>'不支持计算收益支付方式','name'=>'fee_paytype','options'=>'credit_type','help'=>'说明：举例勾选抵扣券不支持分红；那么使用实际现金支付将减去抵扣券的额度不计算分红；'),
							array('type'=>'title','title'=>'收益结算提现设置'),
							array('type'=>'checkbox','title'=>'支持的提现方式','name'=>'withdrawtype','options'=>'withdraw'),
							array('type'=>'unitstring','unit'=>'元','title'=>'结算额度（元）','name'=>'balance_money','help'=>'收益达到该数值才能结算'),
							array('type'=>'unitstring','title'=>'收益结算扣除服务费（%）','unit'=>'%','name'=>'balance_per'),
							array('type'=>'switch','title'=>'下单即可结算？','isradio'=>1,'name'=>'isbuy_jiesuan','help'=>'不开启，则表示，必须完成订单才能结算！'),
							array('type'=>'string','title'=>'结算天数','name'=>'balance_day','help'=>'当订单完成后的n天后，收益才能申请提现,设置0或空，订单完成就可以结算'),
						)
			),
			array(
				'title'=>'底部导航',
					'list'=>array(
							array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标','help'=>'图标，例如：icon-shouye'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
							),
					)
			),
		)
	);
	$return['levels']=$this->getall('teamlevel',array('uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['levels']['0']=array('id'=>0,'title'=>'全部等级');
	$return['leveltype']=$this->level_up_types;
	$return['agent_types']=$this->agent_types;
	$return['commissiontype']=$this->commission_types;
	$return['become']=array('1'=>'后台指定','2'=>'自由申请','3'=>'按团长等级申请');
    $return['types']=array('默认极差模式','普通分红模式');
	$return['area_level']=$this->area_level;
	$return['gift_type']=$this->gift_type;
	$return['credit_type']=$this->credit_type;
	$return['withdraw']=$this->pay_types;
	$return['htmls']=$htmls;
	exi($return);
}


